# 导入蓝图
from flask import Blueprint,request
import json
# 导入db
from db import db1
# 
bp_goods=Blueprint('goods',__name__)

@bp_goods.route('/goodsM',methods=['POST'])
def goodsM():
    #获取用户输入
    data=request.data
    if data:
        data=json.loads(data)
    else:
        data=request.form
    #构造sql语句
    sql="insert into goods values(0,'%s',%d)"%(data['name'],int(data['cid']))
    #pymsql
    db1.insert(sql)
    #返回结果
    return 'ok'